<?php
/**
 * Filter input parameters 
 *
 * Filters input parameters to prevent cross site scripting
 *
 * @category   
 * @package    
 * @subpackage 
 * @copyright 
 * @author     Sandeep Manne<sandeep.manne@costrategix.com>
 */

class Core_Helper_GetFilteredParams extends Zend_Controller_Action_Helper_Abstract
{
	/**
     * @var Zend_Loader_PluginLoader
     */
    public $pluginLoader;

    /**
     * Constructor: initialize plugin loader
     * 
     * @return void
     */
    public function __construct()
    {
        $this->pluginLoader = new Zend_Loader_PluginLoader();
    }
    
    public function filterParams()
    {
    	$params = $this->getRequest()->getParams();
    	$filteredParams = array();
		foreach ($params as $key => $param)
		{
			if (is_array($param)) {
				$filteredParams[$key] = $param;
				continue; 
			}
			
			$filteredParams[$key] = htmlentities(trim($param));		
		}
		return $filteredParams;
    }
    
	/**
     * Strategy pattern: call helper as broker method
     * 
     * @param  string $name 
     * @param  array|Zend_Config $options 
     * @return Zend_Form
     */
    public function direct()
    {
        return $this->filterParams();
    }
}